import React from 'react'
import ReactDom from 'react-dom'
import { BrowserRouter } from 'react-router-dom'
import { renderRoutes } from 'react-router-config'
import { Provider } from 'react-redux'
import {getClientStore} from '../store'

import routes from '../routes'

const Root = () => {
  return (
    // 通过 Provider 组件将 store 传递给其子组件
    <Provider store={getClientStore()}>
      <BrowserRouter>{
        <div>
          {renderRoutes(routes)}
        </div>
      }</BrowserRouter>
    </Provider>
  )
}

ReactDom.hydrate(<Root />, document.getElementById('root'))
// ReactDom.render(<App />, document.getElementById('root'))
